/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __LIB3D_HARD_VERTEX_BUFFER_H__
#define __LIB3D_HARD_VERTEX_BUFFER_H__

#include "IndexBuffer.h"
#include <SimpleArray.h>

namespace liba
{
namespace lib3d
{
namespace hard
{

enum PrimitivesType
{
	TRIANGLESLIST,
	TRIANGLESSTRIP,
	LINESLIST,
	LINESSTRIP
};
	
class VertexBuffer
{
public:
	VertexBuffer();
	virtual ~VertexBuffer();
	
	virtual bool is_valid()const=0;
	/** returns false if parameters combination is bad */
	virtual bool update(
		const SimpleArray<float> & positions,
		const SimpleArray<float> & normals,
		const SimpleArray<float> & u_tangents,
		const SimpleArray<float> & v_tangents,
		const SimpleArray<float> & uv0,
		const SimpleArray<float> & uv1,
		const SimpleArray<float> & weights0,
		const SimpleArray<float> & weights1,
		const SimpleArray<float> & weights2,
		const SimpleArray<int> & indices0,
		const SimpleArray<int> & indices1,
		const SimpleArray<int> & indices2,
		const SimpleArray<int> & indices3
		)=0;
	/** returns false if parameters combination is bad */
	/** added by Max to support color-vertices */
	virtual bool update(
		const SimpleArray<float> & positions,
		const SimpleArray<float> & normals,
		const SimpleArray<float> & colors,
		const SimpleArray<float> & uv0,
		const SimpleArray<float> & uv1
		)=0;
	virtual void set_primitives_type(PrimitivesType primitiveType)
	{
	}
	virtual bool render( int vertex_pos, int primitive_count )=0;
	virtual bool render( IndexBuffer * ib, int index_pos, int primitive_count, int vertex_pos, int vertex_count )=0;
	virtual bool render( VertexBuffer * vb2, int vertex_pos, int primitive_count )=0;
	virtual bool render( VertexBuffer * vb2, IndexBuffer * ib, int index_pos, int primitive_count, int vertex_pos, int vertex_count )=0;
	
	static void report_usage();
};

} // namespace hard
} // namespace lib3d
} // namespace liba
using namespace liba;

#endif //__LIB3D_HARD_VERTEX_BUFFER_H__

